<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>更新资源类别</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="res/js/jquery-1.2.6.js"></script>
	<script type="text/javascript">
	
	function onload() {
		var shareType = <%=session.getAttribute("shareType")%>;
		if(shareType == null) {
			shareType = 0;	//default is comm shared
		}
		var shareTypeRadio = document.getElementsByName("shareWay");
		for(var i = 0;i<shareTypeRadio.length;i++) {
			var radioItem = shareTypeRadio[i];
			if(radioItem.value == shareType) {
				radioItem.checked = "checked";
			}
			radioItem.disabled = "disabled";
		}
		$.post("res/getResType.action",{"superId":"0"},resTypeCB,"json");
	}
	function resTypeCB(data) {
		var superType = $("#superType");
		if(data == null || data == "") {
			superType.html("<option>暂无分类</option>");
			return;
		}
		var json = data.types;
		superType.html("<option value=\"0\">请选择</option>");
		for(var i = 0;i<json.length;i++) {
			var item = json[i];
			superType.append("<option value=\""+ item.id + "\">" + item.name + "</option>");
		}
	}
	
	function getTypeItem(value) {
		if(value == 0) {
			var superType = $("#type");
			superType.html("<option value=\"0\">请选择</option>");
			return;
		}
		$.post("res/getResType.action",{"superId":value},resTypeItem,"json");
	}
	function resTypeItem(data) {
		var superType = $("#type");
		if(data == null || data == "") {
			superType.html("<option>暂无分类</option>");
			return;
		}
		var json = data.types;
		superType.html("<option value=\"0\">请选择</option>");
		for(var i = 0;i<json.length;i++) {
			var item = json[i];
			superType.append("<option value=\""+ item.id + "\">" + item.name + "</option>");
		}
	}
	
	function check() {
		if(confirm("确定要修改吗？")) {
			return true;
		}
		return false;
	}
	</script>
	<style type="text/css">
		*{
			font-size:12px;
		}
	</style>
  </head>
  
  <body onload="javascript:onload();" style="font-size:12px;">
  	<form action="res/updateResInfoType.action" method="post" onsubmit="javascript:return check();">
	    <table>
	    	<tr>
	    		<td width="80">资源名称：</td>
	    		<td><input name="resId" type="hidden" value="${item.id }" />${item.name }</td>
	    	</tr>
	    	<tr>
	    		<td width="80">原类别：</td>
	    		<td>${type.name }</td>
	    	</tr>
	    	<tr>
	    		<td>要修改的类别：</td>
	    		<td>
   					<select id="superType" style="width:120px;border:1px solid #5596be" onchange="javascript:getTypeItem(this.value);">
   					</select>
   					<select id="type" name="type" style="width:120px;border:1px solid #5596be">
   						<option value="0">请选择</option>
   					</select>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td colspan="2"><input type="submit" value="修改" /></td>
	    	</tr>
	    </table>
    </form>
  </body>
</html>
